我正在尝试对csv文件/数据库中的所有ticker值运行无限循环。 我打算用一些基本的示例代码来提问,但是我认为提供上下文帮助理解是很重要的
如果我以当前的方式运行它,将在下一次之后检查一个ticker。我要同时检查所有的股票行情
这是我正在从事的项目的当前代码:
import pandas as pd
import numpy as np
import yfinance as yf
import datetime as dt
import matplotlib.pyplot as plt
import yahoo_fin
from pandas_datareader import data as pdr
from scipy import stats
from scipy.stats import linregress
import scipy.signal as sc
from yahoo_fin import stock_info as si
import winsound
from ib_insync import *
from multiprocessing import Process
with open('sellerdf.csv', 'r') as csv_file:
csv_reader=csv.reader(csv_file)
ib=IB()
ib.connect('127.0.0.1', 7497, clientId=1)
while True:
try:
for line in csv_reader:
ticker=line[1]
quantity=line[2]
channel=line[3]
pricebefore=si.get_live_price(ticker)
time.sleep(60)
priceafter =si.get_live_price(ticker)
if priceafter>pricebefore:
stoploss = priceafter *0.99
time.sleep(20)
else:
stoploss=pricebefore*0.99
time.sleep(20)
new_currentprice=si.get_live_price(ticker)
if channel*1.01 > new_currentprice < stoploss:
order = MarketOrder('SELL', quantity)
stock=(ticker, 'NYSE', 'USD')
ib.qualifyContracts(stock)
trade=ib.placeOrder(stock, order)
trade.log()
trade.orderStatus.status()
目前没有回答
相关问题 更多 >
编程相关推荐