پال "دی گیمر" لیوی

مصنف:فاکس پین، تاریخ: 2018-09-20 19:23:53
ٹیگز:ٹھیک ہےمارٹنگیلپائیتھون

فیوچر جوئے بازی کی حکمت عملی
اگر آپ غلط سمت میں جاتے ہیں تو آپ کو خود کار طریقے سے ریورس ڈبل ڈبل ہو جاتا ہے.

ہم نے اس کے بارے میں کیا سوچا ہے؟

ہم نے اس کے بارے میں کیا سوچا ہے؟

ہم نے اس کے بارے میں کیا سوچا ہے؟

ہم نے اس کے بارے میں کیا سوچا ہے؟




#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# encoding: utf-8
#
#  Paul "The Gambler" Lévy.
#
# Copyright 2018 FawkesPan
# Contact : i@fawkex.me / Telegram@FawkesPan
#
# Do What the Fuck You Want To Public License
#

import random
from math import *

Account = {}
Ticker = {}
LPosition = 0
SPosition = 0
Positions = {}
TotalLoss = 0
TotalWin = 0
FullLoss = 0
MaxPosition = 0
TotalLongs = 0
TotalShorts = 0

def cancelAllOrders():
    orders = exchange.GetOrders()
    for order in orders:
        exchange.CancelOrder(order['Id'], order)
    return True

def updateMarket():
    global Ticker

    Ticker = exchange.GetTicker()

    return True

def updateAccount():
    global Account
    global LPosition
    global SPosition
    global Positions
    global MaxPosition

    LPosition = 0
    SPosition = 0
    Positions = {}
    for item in exchange.GetPosition():
        if item['MarginLevel'] == LEVERAGE_RATE:
            if item['Type'] == 1:
                Positions['Short'] = item
                SPosition += item['Amount']
            else:
                Positions['Long'] = item
                LPosition += item['Amount']
        MaxPosition = max(MaxPosition, SPosition, LPosition)

    Account = exchange.GetAccount()

    return True

def updatePositions():
    global TotalWin
    global TotalLoss
    global FullLoss

    opened = False

    try:
        Long = Positions['Long']['Amount']
        LongEntry = Positions['Long']['Price']
        Current = Ticker['Sell']

        StopLoss = LongEntry * (1-STOP_LOSS)
        TakeProfit = LongEntry * (1+TAKE_PROFIT)

        if Current > TakeProfit:
            Risked = True
            Log('多仓达到预设止盈价位. #0000FF')
            TotalWin+=1
            Log('总计止盈次数: ', TotalWin, ' 总计止损次数: ', TotalLoss, ' 完全止损次数: ', FullLoss, ' 持有过的最大仓位: ', MaxPosition, ' 总计开多: ', TotalLongs, ' 总计开空: ', TotalShorts)
            coverLong(Long, True)
        if Current < StopLoss:
            Risked = True
            Log('多仓达到预设止损价位. #FF0000')
            TotalLoss+=1
            Log('总计止盈次数: ', TotalWin, ' 总计止损次数: ', TotalLoss, ' 完全止损次数: ', FullLoss, ' 持有过的最大仓位: ', MaxPosition, ' 总计开多: ', TotalLongs, ' 总计开空: ', TotalShorts)
            coverLong(Long, True)
            if Long*AMP < RISK_LIMIT:
                openShort(Long*AMP, True)
            else:
                FullLoss+=1
                Log('超过允许的最大仓位,停止开仓. #FF0000')
                Log('总计止盈次数: ', TotalWin, ' 总计止损次数: ', TotalLoss, ' 完全止损次数: ', FullLoss, ' 持有过的最大仓位: ', MaxPosition, ' 总计开多: ', TotalLongs, ' 总计开空: ', TotalShorts)

        opened = True
    except KeyError:
        pass

    try:
        Short = Positions['Short']['Amount']
        ShortEntry = Positions['Short']['Price']
        Current = Ticker['Buy']

        StopLoss = ShortEntry * (1+STOP_LOSS)
        TakeProfit = ShortEntry * (1-TAKE_PROFIT)

        if Current < TakeProfit:
            Risked = True
            Log('空仓达到预设止盈价位. #0000FF')
            TotalWin+=1
            Log('总计止盈次数: ', TotalWin, ' 总计止损次数: ', TotalLoss, ' 完全止损次数: ', FullLoss, ' 持有过的最大仓位: ', MaxPosition, ' 总计开多: ', TotalLongs, ' 总计开空: ', TotalShorts)
            coverShort(Short, True)
        if Current > StopLoss:
            Risked = True
            Log('空仓达到预设止损价位. #FF0000')
            TotalLoss+=1
            Log('总计止盈次数: ', TotalWin, ' 总计止损次数: ', TotalLoss, ' 完全止损次数: ', FullLoss, ' 持有过的最大仓位: ', MaxPosition, ' 总计开多: ', TotalLongs, ' 总计开空: ', TotalShorts)
            coverShort(Short, True)
            if Short*AMP < RISK_LIMIT:
                openLong(Short*AMP, True)
            else:
                FullLoss+=1
                Log('超过允许的最大仓位,停止开仓. #FF0000')
                Log('总计止盈次数: ', TotalWin, ' 总计止损次数: ', TotalLoss, ' 完全止损次数: ', FullLoss, ' 持有过的最大仓位: ', MaxPosition, ' 总计开多: ', TotalLongs, ' 总计开空: ', TotalShorts)

        opened = True
    except KeyError:
        pass

    if not opened:
        Log('还没开仓,随便开个仓位.')
        rand = random.choice([1,2,3,4,5,6])
        if rand in [1,3,5]:
            Log('骰子抛到了: ',rand,' 正在开多.')
            openLong(START_SIZE, True)
        else:
            Log('骰子抛到了: ',rand,' 正在开空.')
            openShort(START_SIZE, True)

    return True

def openLong(Amount=0, marketPrice=False):
    global TotalLongs

    Amount = floor(Amount)

    TotalLongs+=Amount

    exchange.SetDirection('buy')

    if marketPrice:
        exchange.Buy(Ticker['Sell']*1.01, Amount)
    else:
        exchange.Buy(Ticker['Sell'], Amount)

    return True

def coverLong(Amount=0, marketPrice=False):
    exchange.SetDirection('closebuy')

    if marketPrice:
        exchange.Sell(Ticker['Buy']*0.99, Amount)
    else:
        exchange.Sell(Ticker['Buy'], Amount)

    return True

def openShort(Amount=0, marketPrice=False):
    global TotalShorts

    Amount = floor(Amount)

    TotalShorts+=Amount

    exchange.SetDirection('sell')

    if marketPrice:
        exchange.Sell(Ticker['Buy']*0.99, Amount)
    else:
        exchange.Sell(Ticker['Buy'], Amount)

    return True

def coverShort(Amount=0, marketPrice=False):
    exchange.SetDirection('closesell')

    if marketPrice:
        exchange.Buy(Ticker['Sell']*1.01, Amount)
    else:
        exchange.Buy(Ticker['Sell'], Amount)

    return True

def onTick():
    cancelAllOrders()
    updateMarket()
    updateAccount()
    updatePositions()

    return True

def main():
    exchange.SetContractType(CONTRACT_TYPE)
    exchange.SetMarginLevel(LEVERAGE_RATE)

    while True:
        onTick()
        Sleep(DELAY*1000)


متعلقہ

مزید

a8269917آپریشن کی فیس ہے ، 7 سے 8 بار جیتنے یا پیسہ کمانے کے لئے ، خطرہ بھی خاص طور پر بڑا ہے۔ جیتنے کے ل accurate آپ کو درستگی بڑھانا ہوگی ، تجارت کھولنے کی تعداد کو کم کرنا ہوگا۔ MACD کو رجحان اشارے کے طور پر استعمال کریں تاکہ تجارت کی سمت کا تعین کیا جاسکے ، پہلے دو یا تین بار $ 1 ، 2 ، 4 کے ساتھ آزمائشی ، اگر ناکام ہوجائیں تو چوتھی فہرست میں 100 ڈالر دوگنا ہونا شروع ہوجاتے ہیں ، یہ محسوس ہوتا ہے کہ حقیقی دوگنا کرنا 5 بار تک کوئی معنی نہیں رکھتا ہے ، ذاتی رائے صرف حوالہ کے لئے ہے۔

فاکس پین136 - 144 لائنوں کو کھولنے کی منطق ہے. آپ اسے تبدیل کر سکتے ہیں اور اسے اپنے آپ کو آزما سکتے ہیں.